**********************************************************************************	
*** TABLE A8: Dynamic Effect of Hearings on IP Rate, Other Hearing Effects
**********************************************************************************
		
use "$DATALOC/AgencyLevel.dta", clear
* Previous number of hearings
eststo app_a_prev: reghdfe iprate agen_hear_all last_agen_hear agen_prevsum_nhearb,  a(agency FY)	
	quietly estadd local fixedyear "Yes", replace
	quietly estadd local fixedagency "Yes", replace
	estadd ysumm, replace	
* Hearing spillover
eststo app_a_spill: reghdfe iprate agen_hear_spill last_agen_hear_spill agen_hear_all last_agen_hear,  a(agency FY, savefe)
	quietly estadd local fixedyear "Yes", replace
	quietly estadd local fixedagency "Yes", replace
	estadd ysumm, replace	
* Hearing X statute-year
eststo app_a_statute: reghdfe iprate agen_hear_all last_agen_hear agen_hearXstatute, a(agency FY, savefe)
	quietly estadd local fixedyear "Yes", replace
	quietly estadd local fixedagency "Yes", replace
	estadd ysumm, replace
* Proportion of hearings
* excludes 2019-2021
drop if FY>=2019
eststo app_a_prop: reghdfe iprate agen_prop_all last_agen_hear lXagen_prop_last_hr, a(agency FY, savefe)
	quietly estadd local fixedyear "Yes", replace
	quietly estadd local fixedagency "Yes", replace
	estadd ysumm, replace

use "$DATALOC/ProgramLevel.dta", clear
* Previous number of hearings
eststo app_p_prev: reghdfe iprate agen_hear_all last_agen_hear agen_prevsum_nhearb,  a(programname FY, savefe) $CLUSTERCODE
	quietly estadd local fixedyear "Yes", replace
	quietly estadd local fixedagency "Yes", replace
	estadd ysumm, replace
* Hearing spillover
eststo app_p_spill: reghdfe iprate agen_hear_spill last_agen_hear_spill agen_hear_all last_agen_hear,  a(programname FY, savefe) $CLUSTERCODE
	quietly estadd local fixedyear "Yes", replace
	quietly estadd local fixedagency "Yes", replace
	estadd ysumm, replace		
* Hearing X statute-year
eststo app_p_statute: reghdfe iprate agen_hear_all last_agen_hear agen_hearXstatute, a(programname FY, savefe) $CLUSTERCODE
	quietly estadd local fixedyear "Yes", replace
	quietly estadd local fixedagency "Yes", replace
	estadd ysumm, replace	
* Proportion of hearings
* excludes 2019-2021
drop if FY>=2019
eststo app_p_prop: reghdfe iprate agen_prop_all last_agen_hear lXagen_prop_last_hr, a(programname FY, savefe) $CLUSTERCODE
	quietly estadd local fixedyear "Yes", replace
	quietly estadd local fixedagency "Yes", replace
	estadd ysumm, replace

	

*** OUTPUT TABLE
esttab app_a_prev app_a_spill app_a_statute app_a_prop app_p_prev app_p_spill app_p_statute app_p_prop using "$TABLELOC/TableA08.tex", ///
	prehead("\begin{sidewaystable}[htbp]\centering \def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi} \caption{Dynamic Effect of Hearings on Improper Payment Rate, Other Hearing Effects.  Dependent variable is improper payment rate as a percent of all payments.} \begin{tabular}{l*{9}{c}} \toprule") ///
	b(a2) fragment ///
	booktabs label se star(** 0.05 *** 0.01)s(fixedyear fixedagency N, label("Fiscal Year FE" "Agency/Program FE" "Observations")) ///
	order(last_agen_hear last_agen_hear_spill lXagen_prop_last_hr agen_hear_all agen_prevsum_nhearb agen_hear_spill agen_hearXstatute) keep(last* agen* l*) ///
	nomtitles ///
	mgroups("Agency-level" "Program-level", ///
				pattern(1 0 0 0 1 0 0 0) ///
				span prefix(\multicolumn{@span}{c}{) suffix(})) ///
	prefoot("\hline") ///
	postfoot("\bottomrule \multicolumn{3}{l}{\footnotesize Standard errors in parentheses; clustered on agency-year for program-level analysis.}\\ \multicolumn{8}{l}{\footnotesize Columns (4) and (8) exclude fiscal years 2019-2021 due to data limitations on the count of \emph{non-}IP hearings agencies} \\ \multicolumn{8}{l}{\footnotesize are called for in fiscal years 2019-2021, the denominator for \emph{Prop. Hearings on IP}.} \\ \multicolumn{3}{l}{\footnotesize \sym{**} \(p<0.05\), \sym{***} \(p<0.01\)}\\ \end{tabular}  \\ \label{tab:otherhear} \end{sidewaystable}") replace
		
	
	
	
